package com.tuanzi.loan.web.bean.family.largeamount;

import com.tuanzi.loan.business.service.family.LoanLargeAmountGongZhongUserInfoService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.vo.response.family.largeamount.LoanLargeAmountGzhResponse;
import com.tuanzi.loan.web.bean.CurrentUserBean;
import com.tuanzi.loan.web.configuration.JSFInfoBean;
import com.tuanzi.server.loan_base.constant.largeamount.LargeAmountConstant;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;
import java.util.Map;

/**
 * User: liangZongXi
 * Create time: 14:19 2019/3/29
 * Description:
 */

@Data
@Slf4j
@Debug
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class LoanLargeAmountGzhDetailBean extends JSFInfoBean<LoanLargeAmountGzhResponse> {

    @Autowired
    private CurrentUserBean currentUserBean;
    @Autowired
    private LoanLargeAmountGongZhongUserInfoService loanLargeAmountGongZhongUserInfoService;

    public Map<String, String> map = LargeAmountConstant.INFO_MAP;

    private static final long serialVersionUID = 302279397841312495L;

    @PostConstruct
    private void init(){
        String id = getParamFromRequest("id");
        if(StringUtils.isBlank(id) || !NumberUtils.isNumber(id)){
            forceRedirect(currentUserBean.getBack());
            return;
        }

        $ = loanLargeAmountGongZhongUserInfoService.findUserInfoAndUserAppyByUserInfoId(Long.valueOf(id));
        if(null == $){
            forceRedirect(currentUserBean.getBack());
        }
    }

    public String onReturn(){
        return redirect(currentUserBean.getBack());
    }
}
